package com.yikes.yygh.config.properties;

import cn.hutool.core.lang.Assert;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 *
 * </p>
 *
 * @Author: guanrong.yin
 * @Date: 2024/12/17 14:41
 * @Version: 1.0
 */
@ConfigurationProperties(prefix = "aliyun.sms")
@Configuration
@Data
@Slf4j
public class SmsProperties implements InitializingBean {

    /**
     * 地址
     */
    private String host;

    /**
     * 路径
     */
    private String path;

    /**
     * app钥匙
     */
    private String appKey;

    /**
     * app 密钥
     */
    private String appSecret;

    /**
     * 应用code
     */
    private String appCode;

    /**
     * 短信签名 ID
     */
    private String smsSignId;

    /**
     * 模板 ID
     */
    private String templateId;

    public static String HOST;
    public static String PATH;
    public static String APP_KEY;
    public static String APP_SECRET;
    public static String APP_CODE;
    public static String SMS_SIGN_ID;
    public static String TEMPLATE_ID;


    @Override
    public void afterPropertiesSet() {

        log.info("Alibaba Sms init...");
        Assert.notBlank(host, "Alibaba Sms host can not be null");
        Assert.notBlank(path, "Alibaba Sms path can not be null");
        Assert.notBlank(appKey, "Alibaba Sms appKey can not be null");
        Assert.notBlank(appSecret, "Alibaba Sms appSecret can not be null");
        Assert.notBlank(appCode, "Alibaba Sms appCode can not be null");
        Assert.notBlank(smsSignId, "Alibaba Sms smsSignId can not be null");
        Assert.notBlank(templateId, "Alibaba Sms templateId can not be null");

        HOST = host;
        PATH = path;
        APP_KEY = appKey;
        APP_SECRET = appSecret;
        APP_CODE = appCode;
        SMS_SIGN_ID = smsSignId;
        TEMPLATE_ID = templateId;

    }

}
